<template>
  <div class="app-container">
    <el-card class="box-card">
      <el-form ref="form" :model="form" >
        <el-descriptions  title="监管任务信息" style="text-align: center" :column="4" border >
          <el-descriptions-item label="流水号" :span="2" label-class-name="my-label" :contentStyle='contentStyle' :labelStyle="labelStyle" >{{ form.sequenceNumber}}</el-descriptions-item>
          <el-descriptions-item label="合同编号" :span="2" label-class-name="my-label" :contentStyle='contentStyle' :labelStyle="labelStyle" >{{ form.contractNo }}</el-descriptions-item>
          <el-descriptions-item label="监管Js代表室" :span="2" label-class-name="my-label" :contentStyle='contentStyle' :labelStyle="labelStyle" >
            <dict-tag :options="dict.type.yh_representative_office" :value="form.note1" />
          </el-descriptions-item>
        </el-descriptions>
        <br/>
        <el-descriptions  title="合同资料信息" style="text-align: center" :column="4" border >
          <el-descriptions-item label="合同资料名称" :span="2" label-class-name="my-label" :contentStyle='contentStyle' :labelStyle="labelStyle" >{{ form.contractFileName}}</el-descriptions-item>
          <el-descriptions-item label="合同资料标识" :span="2" label-class-name="my-label" :contentStyle='contentStyle' :labelStyle="labelStyle" >{{ form.contractFileId }}</el-descriptions-item>
          <el-descriptions-item label="合同资料类别" :span="2" label-class-name="my-label" :contentStyle='contentStyle' :labelStyle="labelStyle" >
            <dict-tag :options="dict.type.yh_contract_file_type" :value="form.contractFileType" />
          </el-descriptions-item>
          <el-descriptions-item label="合同资料下载" :span="4" label-class-name="my-label" :labelStyle="labelStyle" > <el-button type="primary"  plain size="mini" @click="downloadEvt">资料下载</el-button></el-descriptions-item>
          <el-descriptions-item label="备注" :span="4" label-class-name="my-label" :labelStyle="labelStyle" >{{ form.remark }}</el-descriptions-item>
        </el-descriptions>
      </el-form>
      <br/>
      <div style="float:right; margin-bottom: 15px;">
        <el-button @click="viewCancel">返 回</el-button>
      </div>
    </el-card>
  </div>
</template>

<script>
  import { listFile, getFile, delFile, addFile, updateFile } from "@/api/module/cjl/data";
  import { treeselect } from "@/api/system/dept";
  import Treeselect from "@riophae/vue-treeselect";
  import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  import watermark from "watermark-dom";
  export default {
    name: "File",
    dicts: ['yh_contract_file_type','yh_representative_office'],
    components: { Treeselect },
    data() {
      return {
        contentStyle: {
          'width': '180px',
        },
        labelStyle: { 'width': '140px','color': '#000000','text-align': 'right', },
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: false,
        // 总条数
        total: 0,
        // 部门树选项
        deptOptions: undefined,
        // 合同资料表格数据
        fileList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          sequenceNumber: null,
          contractNo: null,
          contractFileName: null,
          contractFileUrl: null,
          contractFileId: null,
          contractFileType: null,
          createBy: null,
          createTime: null,
          updateBy: null,
          updateTime: null,
          remark: null,
          note1: null,
          note2: null,
          note3: null,
          note4: null,
          note5: null,
          note6: null,
          note7: null,
          note8: null,
          note9: null,
          note10: null
        },
        // 表单参数
        form: {},

      };
    },
    mounted() {
      watermark.load({ watermark_txt: "  "   });
    },
    created() {
     const id = this.$route.query.id;
      if (id) {
        // 获取表详细信息
        getFile(id).then(res => {

          this.form = res.data;

        });

      }
    },
    methods: {
      downloadEvt(url, fileName = '合同资料文件') {
          const el = document.createElement('a');
          el.style.display = 'none';
          el.setAttribute('target', '_blank');
          fileName && el.setAttribute('download', fileName);
          url= this.$store.state.user.ipaddress+this.form.contractFileUrl
          el.href = url;
          console.log(el);
          document.body.appendChild(el);
          el.click();
          document.body.removeChild(el);
      },
      /** 关闭按钮 */
      viewCancel() {
        const id = this.$route.query.id;
        getFile(id).then(response => {
          this.form = response.data;

        });
        const obj = {path: "/hetong/cjldata", query: {id}};
        this.$tab.closeOpenPage(obj);

      },

      /** 查询部门下拉树结构 */
      getTreeselect() {
        treeselect().then(response => {
          this.deptOptions = response.data;
        });
      },
    }
  };
</script>
<style lang="scss" scoped>


</style>
